package org.xyl.game.tool.serializer;

import com.google.gson.*;
import io.swagger.models.auth.In;
import org.springframework.core.serializer.Serializer;
import org.xyl.game.entity.Mygame;
import org.xyl.game.entity.Userinfo;
import springfox.documentation.spring.web.json.Json;

import java.lang.reflect.Type;

public class MygameSerializer implements JsonSerializer<Mygame> {
    @Override
    public JsonElement serialize(Mygame mygame, Type type, JsonSerializationContext jsonSerializationContext) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.add("roomid", new JsonPrimitive(Integer.toString(mygame.getRoomid())));
        jsonObject.add("username", new JsonPrimitive(mygame.getUsername()));
        jsonObject.add("mycount", new JsonPrimitive(Integer.toString(mygame.getMycount())));
        jsonObject.add("result", new JsonPrimitive(mygame.getResult()));
        return jsonObject;
    }
}
